﻿use sms
go
if exists(select name from sysobjects where name ='cp_query_to_besend' and type = 'P')
drop procedure cp_query_to_besend
go  
--查找所有待发送的信息
create procedure cp_query_to_besend
as
--return dataset
if((select COUNT(*) from [Message] where [State] & 0xf0 = 0x00) != 0)
	begin
		select * from [Message] where [State] & 0xf0 = 0x00 order by Priority
	end
else
	begin
		--没有记录时返回空集合
		select * from [Message]  where [State] = -1
	end
go